package com.jp.proxy.httpprocessor;

import android.app.Application;

import org.xutils.common.Callback;
import org.xutils.http.RequestParams;
import org.xutils.x;

import java.util.Map;

/**
 * @ProjectName : HttpProcessor_20200413
 * @Author : Jason
 * @Time : 2021/8/29 14:06
 * @Description : 文件描述
 */
public class XUtilsProcessor implements IHttpProcessor {


    public XUtilsProcessor(Application app) {
        x.Ext.init(app);
    }

    @Override
    public void postRequest(String url, Map<String, Object> map, IRequestCallBack iRequestCallBack) {
        RequestParams requestParams = new RequestParams(url);
        x.http().post(requestParams, new Callback.CommonCallback<String>() {
            @Override
            public void onSuccess(String result) {
                iRequestCallBack.onSuccess(result);
            }

            @Override
            public void onError(Throwable ex, boolean isOnCallback) {
                iRequestCallBack.onFailure(ex.getMessage());
            }

            @Override
            public void onCancelled(CancelledException cex) {

            }

            @Override
            public void onFinished() {

            }
        });
    }

    @Override
    public void get(String url, Map<String, Object> params, IRequestCallBack callback) {
    }
}
